package com.example.demo;

import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
@WebEndpoint(id = "status")
public class StatusEndPoint implements ApplicationContextAware{
	
	private ApplicationContext applicationContext;
	
	@ReadOperation
	public String name() {
		StatusService bean = applicationContext.getBean(StatusService.class);
		return "================>" + bean.getStatus();
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

}
